﻿@using KMF.WebUI.Areas.KMFadmin.CustomHelpers
@using KMF.WebUI.Areas.KMFadmin.Models
@model IEnumerable<KMF.Common.ViewBannerDto>
@{
    ViewBag.Title = "Banner";
    Layout = "~/Areas/KMFadmin/Views/Shared/_layout.cshtml";
}

<nav>
    <div id="jCrumbs" class="breadCrumb module">
        <ul>
            <li><a href="@Url.Action("Index","AdminHome")"><i class="bootstrap icon-home"></i></a></li>
            <li><a href="javascript:void(0)">Danh sách Banner</a> </li>
        </ul>
    </div>
</nav>

<div class="toolBox">
    @Html.ToolBox(new List<object> { new Add { ClassCss = "Add", ActionName = "/KMFadmin/AdminBanner/AddBanner" } })
</div>
@*<div class="box-search">
    <div class="fl-l"></div>
    @using (Html.BeginForm("SearchBanner", "Banner"))
    {
        @Html.TextBox("keyword")
        <input type="submit" value="Tìm kiếm" />
    }
    <div class="fl-r"></div>
    <div class="clear"></div>
</div>*@
<div style="overflow:hidden;">
    <table class="table-odd table-plist">
        <colgroup>
            <col style="width: 30px" />
            <col style="width: 700px" />
            <col />
            <col />
            <col />
            <col />
            <col />
            <col />
        </colgroup>
        <tr>
            <th scope="col">STT</th>
            <th scope="col">Chủ đề</th>
            <th scope="col">Trang</th>
            <th scope="col">Vị trí</th>
            <th scope="col">Ngày đăng</th>
            <th scope="col">Ngày kết thúc</th>
            <th scope="col">Hiển thị</th>
            <th scope="col"></th>
        </tr>
        @foreach (var item in Model)
        {
            <tr class="@string.Format("bn-{0}", item.BannerId)">
                <td>@item.STT</td>
                <td>
                    @item.Subject
                </td>
                <td>
                    @item.PageName
                </td>
                <td>
                    @item.PositionName
                </td>
                <td>
                    @item.StartDate.ToString("dd/MM/yy")
                </td>
                <td>
                    @item.ExpireDate.ToString("dd/MM/yy")
                </td>
                <td>
                    <input type="checkbox" id="@item.BannerId" @string.Format("{0}", item.Active ? "checked" : "") />
                </td>
                <td>
                    <a href="@Url.Action("EditBanner", "AdminBanner", new { id = item.BannerId })" title="chỉnh sửa" class="icon-edit-v2 fl-l bootstrapTangoSmall"></a>
                    @Ajax.ActionLink("Xóa", "DeleteBanner", "AdminBanner", new { bannerId = item.BannerId }, new AjaxOptions
                                                                                                 {
                                                                                                     Confirm = "Bạn chắc chắn muốn xóa Banner này!",
                                                                                                     OnSuccess = "AjaxReturnDataDeleteBanner"
                                                                                                 }, new { @class = "icon-delete fl-l bootstrapTangoSmall", title = "chỉnh sửa" })
                </td>
            </tr>
        }
    </table>
</div>
    <div class="p-paging">
        @Html.PageLinks((PageInfo)ViewBag.PageInfo, i => Url.Action("Index", "AdminBanner", new { page = i }))
    </div>

    @section scripts
{
        <script src="~/Areas/KMFAdmin/Scripts/jquery.unobtrusive-ajax.min.js"></script>
        <script type="text/javascript">
            function AjaxReturnDataDeleteBanner(data) {
                if (data) {
                    window.location = document.URL;
                }
            }
        </script>
    }

